<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Session;

class Base extends Controller
{

    public function _initialize()
    {

        if (empty(Session::get('auth'))){
            $this->redirect('admin/login/index');
            return;
        }

        //获得方法名，控制器名
        $request = Request::instance();
        $controller = $request->controller();
        $method = $request->action();
        //拼接控制器和方法
        $cm = $controller.$method;
        $cjoinm = Session::get('cjoinm');

        //网站所有者拥有所有权限
        if(Session::get('auth')['username'] != '陆林杨'){
            //验证操作权限
            if(empty($cjoinm) || !in_array($cm,$cjoinm)){



                echo "<script>alert('你没有该权限');</script>";die();
            }
        }

    }

    public function _empty()
    {

        $this->redirect(url('admin/index/errorAdmin'));
    }
}